﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Windows.Forms;
using DevComponents.DotNetBar.Controls;
using DevComponents.DotNetBar;
using DevComponents.Editors.DateTimeAdv;
using QLTB.Controllers;
using QuanLyThietBi.Manager;
using QuanLyThietBi.ManagerBase;
using QuanLyThietBi.Entity;

namespace QLTB.Controllers
{
    public class TBL_NguoiQuanLyCtrl
    {
        public void HienthiDGV(DataGridViewX DGV, BindingNavigator BN)
        {
            BindingSource BS = new BindingSource();
            BS.DataSource = TBL_NguoiQuanLyManager.CreateInstant().LayDanhSachQuanLy();
            BN.BindingSource = BS;
            DGV.DataSource = BS;
        }
        // Them nguoi quan ly
        public void ThemMoiNguoiQuanLy(string MaQuanLy, string TenQuanLy, string Diachi, string DienThoai, string Email, string NgaySinh, string TenDN, string MatKhau, string NhomQuanLy)
        {
            TBL_NguoiQuanLyEntity objNguoiQuanLy = new TBL_NguoiQuanLyEntity();
            objNguoiQuanLy.MaQuanLy = MaQuanLy;
            objNguoiQuanLy.HoTen = TenQuanLy;
            objNguoiQuanLy.DiaChi = Diachi;
            objNguoiQuanLy.DienThoai = DienThoai;
            objNguoiQuanLy.Email = Email;
            objNguoiQuanLy.NgaySinh = NgaySinh;
            objNguoiQuanLy.TenDangNhap = TenDN;
            objNguoiQuanLy.MatKhau = MatKhau;
            objNguoiQuanLy.MaNhomQuanLy = NhomQuanLy;
            TBL_NguoiQuanLyManager.CreateInstant().Insert(objNguoiQuanLy);
        }

        //Cap nhat thong tin nguoi quan ly
        public void CapNhatNguoiQuanLy(string MaQuanLy, string TenQuanLy, string Diachi, string DienThoai, string Email, string NgaySinh, string TenDN, string MatKhau, string NhomQuanLy)
        {
            TBL_NguoiQuanLyEntity objNguoiQuanLy = new TBL_NguoiQuanLyEntity();
            objNguoiQuanLy.MaQuanLy = MaQuanLy;
            objNguoiQuanLy.HoTen = TenQuanLy;
            objNguoiQuanLy.DiaChi = Diachi;
            objNguoiQuanLy.DienThoai = DienThoai;
            objNguoiQuanLy.Email = Email;
            objNguoiQuanLy.NgaySinh = NgaySinh;
            objNguoiQuanLy.TenDangNhap = TenDN;
            objNguoiQuanLy.MatKhau = MatKhau;
            objNguoiQuanLy.MaNhomQuanLy = NhomQuanLy;
            TBL_NguoiQuanLyManager.CreateInstant().Update(objNguoiQuanLy);
        }

        // Xoa nguoi quan ly
        public void XoaNguoiQuanLy(string sMaNguoiQuanLy)
        {
            TBL_NguoiQuanLyManager.CreateInstant().DeleteByMaQuanLy(sMaNguoiQuanLy);
        }
       
    }
}
